package com.example.design.generic.test01;

/**
 * @Description 泛型类
 * @date 2022/9/19 9:06
 * @Author liuzhihui
 * @Version 1.0
 */
public class Apple<T> {
    private T weight;

    public T getWeight() {
        return weight;
    }

    public void setWeight(T weight) {
        this.weight = weight;
    }

    public void show(){
        System.out.println("重量是："+weight);
    }

    public static void main(String[] args) {
        Apple<String> stringApple = new Apple<>();
        stringApple.setWeight("122");
        stringApple.show();

        Apple<Integer> a2 = new Apple<>();
        a2.setWeight(500);
        a2.show();

        Apple<Double> a3 = new Apple<>();
        a3.setWeight(500.0);
        a3.show();
    }
}
